package com.vaadin.incubator.bugrap.tests.model;

import java.util.Date;

import org.junit.Test;

import com.vaadin.incubator.bugrap.model.facade.FacadeUtil;
import com.vaadin.incubator.bugrap.model.projects.Project;
import com.vaadin.incubator.bugrap.model.projects.ProjectVersion;

public class ProjectVersionTest extends TestBase {

	@Test
	public void testGetVersion() {
		ProjectVersion pv = new ProjectVersion();
		pv.setVersion("Version");
		pv = FacadeUtil.store(pv);
		assertEquals("Version", pv.getVersion());
	}

	@Test
	public void testSetVersion() {
		ProjectVersion pv = new ProjectVersion();
		pv.setVersion("Version");
		pv = FacadeUtil.store(pv);
		assertEquals("Version", pv.getVersion());
	}

	@Test
	public void testGetReleaseDate() {
		ProjectVersion pv = new ProjectVersion();
		Date d = new Date();
		pv.setReleaseDate(d);
		pv = FacadeUtil.store(pv);
		assertEquals(d, pv.getReleaseDate());
	}

	@Test
	public void testSetReleaseDate() {
		ProjectVersion pv = new ProjectVersion();
		Date d = new Date();
		pv.setReleaseDate(d);
		pv = FacadeUtil.store(pv);
		assertEquals(d, pv.getReleaseDate());
	}

	@Test
	public void testIsClosed() {
		ProjectVersion pv = new ProjectVersion();
		pv.setClosed(true);
		pv = FacadeUtil.store(pv);
		assertTrue(pv.isClosed());

		pv.setClosed(false);
		pv = FacadeUtil.store(pv);
		assertFalse(pv.isClosed());
	}

	@Test
	public void testSetClosed() {
		ProjectVersion pv = new ProjectVersion();
		pv.setClosed(true);
		pv = FacadeUtil.store(pv);
		assertTrue(pv.isClosed());

		pv.setClosed(false);
		pv = FacadeUtil.store(pv);
		assertFalse(pv.isClosed());
	}

	@Test
	public void testGetProject() {
		Project p = new Project();
		p = FacadeUtil.store(p);

		ProjectVersion pv = new ProjectVersion();
		pv.setProject(p);
		pv = FacadeUtil.store(pv);

		assertEquals(p, pv.getProject());
	}

	@Test
	public void testSetProject() {
		Project p = new Project();
		p = FacadeUtil.store(p);

		ProjectVersion pv = new ProjectVersion();
		pv.setProject(p);
		pv = FacadeUtil.store(pv);

		assertEquals(p, pv.getProject());
	}
}
